<div class="container-fluid">
  <div class="row">
    <div class="col-sm-2">
      <%= render "shared/sidenav" %>

    </div>
    <div class="col-sm-10">
      <div class="panel panel-primary">
        <div class="panel-heading">
          <h3 class="panel-title">选修课程</h3>
        </div>
        <div class="panel-body" style="min-height: 450px">
          <%= form_tag("/courses/list", method: "get") do %>
            <%= label_tag(:l_course_time, "上课时间", style:'margin: 0px 0px 0px 60px') %>
            <%= select_tag(:course_time, options_for_select([['不限','不限'],['周一','周一'],['周二','周二'],['周三','周三'],['周四','周四'],['周五','周五']])) %>
            <%= label_tag(:l_course_time, "课程属性", style:'margin: 0px 0px 0px 30px') %>
            <% types=Array.new %>
            <% Course.all.each{|c| types.push([c.course_type,c.course_type]) } %>
            <%= select_tag(:course_type, options_for_select(([['不限','不限']]+types).uniq, 1)) %>
            <%= label_tag(:l_course_name, "课程名称", style:'margin: 0px 0px 0px 30px') %>
            <%= text_field_tag(:course_name, "" ) %>
            <%= submit_tag("查询", class: 'btn-xs btn-primary', style:'margin-left:50px') %>
          <% end %>
          <table class="table table-striped table-hover">
            <thead>

            <tr>
              <th>课程编号</th>
              <th>课程名称</th>
              <th>上课时间</th>
              <th>课时/学分</th>
              <th>限选</th>
              <th>已选</th>
              <th>课程属性</th>
              <th>授课方式</th>
              <th>考试方式</th>
              <th>主讲教师</th>

            </tr>
            </thead>
            <tbody>

            <% @courses.each do |course| %>
                <tr>

                  <td><%= course.course_code %></td>
                  <td><%= course.name %></td>
                  <td><%= course.course_time %></td>
                  <td><%= course.credit %></td>
                  <td><%= course.limit_num %></td>
                  <td><%= course.student_num %></td>
                  <td><%= course.course_type %></td>
                  <td><%= course.teaching_type %></td>
                  <td><%= course.exam_type %></td>
                  <td><%= course.teacher.name %></td>
                  <td><%= link_to "加入课程", select_course_path(course), class: 'btn-sm btn-info' %></td>

                </tr>
            <% end %>
            </tbody>
          </table>
          <%= will_paginate @courses %>
        </div>
      </div>
    </div>
  </div>
</div>


